/**
 * 
 */
package com.wodensoft.core.web;

import java.util.Random;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.wodensoft.core.db.DataPackage;

/**
 * 分页标签
 * 
 * @author Woden Wang
 * @since Feb 20, 2011
 */
@SuppressWarnings("serial")
public class PageBarTag extends TagSupport {

	private static final Logger logger = LoggerFactory.getLogger(PageBarTag.class);

	private String form;
	private DataPackage dp;

	public int doEndTag() throws JspException {
		HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
		try {
			request.setAttribute("dp", dp);
			request.setAttribute("form", form);
			request.setAttribute("random", new Random().nextLong());
			pageContext.include(Actions.Pages.PAGE_BAR_TAG.getPage());
		} catch (Exception e) {
			logger.warn("获取页面文件失败.", e);
		}

		return SKIP_BODY;
	}

	public void setForm(String form) {
		this.form = form;
	}

	public void setDp(DataPackage dp) {
		this.dp = dp;
	}

}
